<include file="common:__head__" />

<div class="permissions-content">
    <div class="permissions-le">
        <span class="add-admin"><a href="javascript:history.go(-1)"></a>订单列表</span>

        <div class="ncap-order-details">
            <form id="order-action">
                <input type="hidden" value="{$order['id']}" id="order_id">
                <div class="tabs-panels">
                    <div class="misc-info">
                        <h3>基本信息</h3>
                        <dl>
                            <dt>订单 ID：</dt>
                            <dd>{$order['id']}</dd>
                            <dt>订单号：</dt>
                            <dd>{$order['order_id']}</dd>
                            <dt>会员：</dt>
                            <dd>{$order['agent_name']}</dd>
                        </dl>
                        <dl>
                            <dt>下单人手机：</dt>
                            <dd>{$order['user_phone']}</dd>
                            <dt>下单时间：</dt>
                            <dd>{$order['time']|date="Y-m-d H:i:s",###}</dd>
                            <if condition="$order['is_pay'] neq -1">
                                <dt>支付方式：</dt>
                                <dd>{$pay_type}</dd>
                            </if>
                        </dl>
                        <dl>
                            <dt>订单状态：</dt>
                            <dd>
                                <if condition="$order['is_pay'] eq -1">
                                    未付款<else /><a class="ft-success">已付款</a>
                                </if>
                                <switch name="order['status']">
                                    <case value="-1"><a class="amt">已取消</a></case>
                                    <case value="1">待确认</case>
                                    <case value="2"><a class="back-color">退款订单</a></case>
                                    <case value="3"><a class="ft-success">交易成功</a></case>
                                </switch>

                                <if condition="$order['is_deliver'] eq -1 AND $order['is_agree'] neq -1">
                                    未发货<elseif condition="$order['is_deliver'] eq -1 AND $order['is_agree'] eq -1"/>
                                    <a class="amt">董事审核不通过</a>
                                    <else /><a class="ft-success">已发货</a>
                                </if>
                            </dd>
                            <dt>订单金额：</dt>
                            <dd><a class="amt">{$order['price']}</a>（含运费）
                                <if condition="$order['is_pay'] eq -1 AND $order['status'] neq -1">
                                    <a class="btn btn-blue modify_price" href="{:U('Order/modify_price', array('id'=>$order['id']))}">修改</a>
                                </if>
                            </dd>
                            <dt>折扣：</dt>
                            <dd><a class="amt">{$order['discount']}</a></dd>
                        </dl>
                    </div>
                    <div class="addr-note">
                        <h4>收货信息</h4>
                        <dl>
                            <dt>收货人：</dt>
                            <dd>{$order['consignee']}</dd>
                            <dt>联系方式：</dt>
                            <dd>{$order['phone']}</dd>
                        </dl>
                        <notempty name="order['code_num']">
                            <dl>
                                <dt>发货单：</dt>
                                <dd>{$order['code_num']}</dd>
                                <dt>发货时间：</dt>
                                <dd>{$order['deliver_time']|date='Y-m-d H:i:s',###}</dd>
                            </dl>
                        </notempty>
                        <dl>
                            <dt>收货地址：</dt>
                            <dd>{$order['detail_area']}</dd>
                        </dl>
                        <dl>
                            <dt>留言：</dt>
                            <dd>{$order['message']}</dd>
                        </dl>
                    </div>

                    <div class="misc-info">
                        <h4>订单流向</h4>
                        <volist name="orderThrough" id="through" key="k" empty="最顶级代理到平台的订单">
                            {$through['agent_name']}
                            <if condition="$through['state'] eq 1">
                                <a class="ft-success">已通过</a>、
                                <elseif condition="$through['state'] eq 0"/>
                                未审核、<else />
                                <a class="amt">不通过</a>
                            </if>
                        </volist>
                    </div>

                    <div class="goods-info">
                        <h4>商品信息</h4>
                        <table border="0">
                            <thead>
                            <tr>
                                <th>商品编号</th>
                                <th>商品图片</th>
                                <th>商品</th>
                                <th>数量</th>
                                <th>小计(元)</th>
                            </tr>
                            </thead>
                            <tbody>
                            <volist name="orderGoods" id="good">
                                <tr>
                                    <td>{$good['id']}</td>
                                    <td><a href="{$good['img']}" target="_blank"><img src="{$good['img']}" class="table-img"/></a></td>
                                    <td>{$good['g_name']|cut_str='15',###}</td>
                                    <td>{$good['num']}</td>
                                    <td>{$good['goods_price']}</td>
                                </tr>
                            </volist>
                        </table>
                    </div>
                    <p style="margin-top: 10px;">
                        <if condition="$order['is_deliver'] eq -1 AND $order['is_platform'] eq 1 AND $order['status'] eq 0 AND $order['is_pay'] eq 1">
                            <a class="btn btn-blue" href="{:U('Order/invoice',array('id'=>$order['id']))}">去发货</a>
                        </if>
                        <if condition="$order['is_deliver'] eq 1 AND $order['is_platform'] eq 1">
                            <a class="btn btn-blue" href="{:U('Order/invoice',array('id'=>$order['id']))}">查看发货单</a>
                        </if>
                        <if condition="$order['status'] neq -1 AND $order['is_deliver'] eq -1">
                            <a class="btn btn-red" data-id="{$order['id']}" id="cancel">取消</a>
                        </if>
                        <if condition="$order['is_pay'] eq -1 AND $order['status'] eq '0'">
                            <a class="btn btn-green do_pay" data-type="pay">付款</a>
                            <elseif condition="$order['is_pay'] eq 1 AND $order['status'] eq '0' AND $order['is_deliver'] eq -1"/>
                            <a class="btn btn-red do_pay" data-type="unpay">取消付款</a>
                        </if>
                    </p>
                </div>
            </form>
        </div>
    </div>
    <div class="permissions-ri">
        <a href="" class="permissions-help">帮助和服务</a>
    </div>
</div>
<script type="text/javascript">
    $(function() {
        $('.do_pay').click(function ()
        {
            $type = $(this).data("type");
            layer.confirm('确认进行此操作么?', {
                    btn: ['确定','取消']
                }, function(){
                    $.ajax({
                        type : 'post',
                        url : "{:U('Order/set_status')}",
                        data : {
                            do_type: $type,
                            id: "{$order['id']}"
                        },
                        success : function(msg){
                            if (msg.status == "success") {
                                layer.msg("操作成功" ,{time: 1500});
                                setTimeout(function(){window.location.reload(); } ,1500);
                            }else{
                                layer.alert(msg.msg);
                            }
                        }
                    })
                }
            );
        });

        $('#cancel').click(function() {
            var _this = $(this);
            layer.confirm('确认取消订单么?', {
                    btn: ['确定','取消']
                }, function(){
                    $.ajax({
                        type : 'post',
                        url : "{:U('Order/cancel')}",
                        data : {
                            'id': _this.data('id')
                        },
                        success : function(msg){
                            if (msg == 1) {
                                window.location.reload();
                            }
                        }
                    })
                }
            );
        });
    });
    function delfun() {
        // 删除按钮
        layer.confirm('确认删除？', {
            btn: ['确定'] //按钮
        }, function () {
            console.log("确定");
        }, function () {
            console.log("取消");
        });
    }
</script>
<include file="common:__foot__" />